package jun.learn.thread.future;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class Test {
	public static void main(String[] args) {
		try {
			ExecutorService pool = Executors.newFixedThreadPool(2);
			MyCallable c2 = new MyCallable();
			MyCallable c3 = new MyCallable();
			MyCallable c4 = new MyCallable();
			Future f2 = pool.submit(c2);
			Future f3 = pool.submit(c3);
			Future f4 = pool.submit(c4);
			
			System.out.println(f2.get());
			System.out.println(f3.get());
			System.out.println(f4.get());
			pool.shutdown();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ExecutionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
